/* FieldUpdate.java
 * 
 * Alfred Olschnoegger
 * 23.05.2008
 */

package application;

import java.util.Collection;

import application.parser.Parser;
import domain.GameObject;
import domain.Hunter;
import domain.game.Game;
import domain.game.GameManager;
import domain.location.Position;
import exceptions.GameNotExistingException;

/**
 * Captures the data out of the domain layer and parses it for the presentation
 * layer.
 * 
 * @date 23.05.2008
 * @author Alfred Olschnoegger
 */
public class FieldUpdate {

	private Game m_Game;

	@SuppressWarnings("unchecked")
	public void getUpdate(int x, int y, String hunterName, int range, int gameID, Parser parse) {
		// TODO Exception Falsche GameID Exception abfangen.
		m_Game = GameManager.getInstance().getGame(gameID);

		if (m_Game != null) {
			Hunter hunter = m_Game.getHunter(hunterName);
			Position position = new Position(x, y);
			hunter.setPos(position.clone());
			Collection<GameObject> objects = m_Game.getRange(position, range);
			for (GameObject o : objects) {
				parse.add(o);
			}

		} else {
			parse.add(new GameNotExistingException());
		}
	}
}

// end of FieldUpdate.java
